package org.hamster.multidropbox.main.view
{
	import icons.IconUtil;
	
	import mx.controls.SWFLoader;
	
	import org.hamster.multidropbox.main.constants.AppStatus;
	
	import spark.components.IItemRenderer;
	import spark.components.Image;
	import spark.components.gridClasses.IGridItemRenderer;
	
	public class StatusIcon extends SWFLoader implements IItemRenderer
	{
		[Embed(source='/swf/loading15.swf')]
		private static var LOADING_SWF:Class;
		private static var mapping:Array;
		public static function get MAPPING():Array
		{
			if (!mapping) {
				mapping = new Array();
				mapping[AppStatus.FOLDER] 	= IconUtil.FOLDER;
				mapping[AppStatus.NO]  		= IconUtil.NO;
				mapping[AppStatus.YES] 		= IconUtil.YES;
				mapping[AppStatus.UNKNOWN] 	= IconUtil.UNKNOWN;
				mapping[AppStatus.FILE] 	= IconUtil.FILE;
				mapping[AppStatus.LOADING] 	= LOADING_SWF;
			}
			return mapping;
		}
		
		private var _status:int;
		
		public function set status(value:int):void
		{
			if (_status != value) {
				_status = value;
				this.source = MAPPING[value];
			}
		}
		
		public function get status():int
		{
			return _status;
		}
		
		public function StatusIcon()
		{
			super();
			width = 48;
			height = 48;
			this.scaleContent = true;
		}
		
		private var _data:Object;
		private var _label:String;
		private var _dragging:Boolean;
		private var _itemIndex:int;
		private var _showsCaret:Boolean;
		private var _selected:Boolean;
		
		public function set data(value:Object):void
		{
			this._data = value;
			if (data) {
				if (data is int) {
					this.status = data as int;
				} else if (data.hasOwnProperty("status")) {
					this.status = data.status;
				}
			}
		}
		
		public function get data():Object
		{
			return this._data;
		}
		
		public function set label(value:String):void
		{
			this._label = value;
		}
		
		public function get label():String
		{
			return this._label;
		}
		
		public function set dragging(value:Boolean):void
		{
			this._dragging = value;
		}
		
		public function get dragging():Boolean
		{
			return this._dragging;
		}
		
		public function set itemIndex(value:int):void
		{
			this._itemIndex = value;
		}
		
		public function get itemIndex():int
		{
			return this._itemIndex;
		}
		
		public function set showsCaret(value:Boolean):void
		{
			this._showsCaret = value;
		}
		
		public function get showsCaret():Boolean
		{
			return this._showsCaret;
		}
		
		public function set selected(value:Boolean):void
		{
			this._selected = value;
		}
		
		public function get selected():Boolean
		{
			return this._selected;
		}
	}
}